/*
*    UNIVERSIDADE DE SÃO PAULO.
*    Author: Marco Aurélio Gerosa (gerosa@ime.usp.br)
*
*    This file is part of Groupware Workbench (http://www.groupwareworkbench.org.br).
*
*    Groupware Workbench is free software: you can redistribute it and/or modify
*    it under the terms of the GNU Lesser General Public License as published by
*    the Free Software Foundation, either version 3 of the License, or
*    (at your option) any later version.
*
*    Groupware Workbench is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU Lesser General Public License for more details.
*
*    You should have received a copy of the GNU Lesser General Public License
*    along with Swift.  If not, see <http://www.gnu.org/licenses/>.
*/
package br.org.groupwareworkbench.collablet.coop.recommend;

import org.dom4j.Element;

import br.org.groupwareworkbench.core.framework.ComponentInfo;
import br.org.groupwareworkbench.core.bd.DAOFactory;
import br.org.groupwareworkbench.core.framework.Component;

@ComponentInfo(
        instanceType=RecommendMgrInstance.class,
        version="0.1",
        configurationURL="/groupware-workbench/{collablet}/recommendMgr/{recommendMgr}/configure"
)
public class RecommendMgrComponent extends Component {

    private final RecommendDAO recommendDAO = DAOFactory.get(RecommendDAO.class);
    private XmlRecommendConfig xmlConfig;

    @Override
    public void whenUninstalling() {
        this.recommendDAO.deleteAll();
    }

    @Override
    protected synchronized void applyConfiguration(Element xml, boolean isNewComponent) {
        xmlConfig = new XmlRecommendConfig(xml);
    }

    public synchronized XmlRecommendConfig getXmlConfig() {
        return xmlConfig;
    }
}
